/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package master.vehicle_class;

import java.awt.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import master.vehicle_class.object.MVehicalClass;
import template.RegistrantionPanel;

/**
 *
 * @author Banuka
 */
public class GUIVehicleClass extends RegistrantionPanel {

    /**
     * Creates new form VehicleClass
     */
    public GUIVehicleClass() {
        initComponents();
        initOthrs();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked") 
    private void initOthrs() {
        vclass = new MVehicalClass();
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        txtCode = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtName = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtDiscription = new javax.swing.JTextArea();
        jLabel4 = new javax.swing.JLabel();
        txtFee = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtMinPaymentForExam = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtMinPaymentForTrial = new javax.swing.JTextField();

        jLabel1.setText("Code :");

        jLabel2.setText("Name :");

        txtName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNameActionPerformed(evt);
            }
        });

        jLabel3.setText("Discription :");

        txtDiscription.setColumns(20);
        txtDiscription.setRows(5);
        jScrollPane1.setViewportView(txtDiscription);

        jLabel4.setText("Fee :");

        jLabel5.setText("Min Payment For Eaxm :");

        jLabel6.setText("Min Payment For Trial :");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addGap(64, 64, 64)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtName, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                            .addComponent(txtCode)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtFee)
                            .addComponent(txtMinPaymentForExam)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtMinPaymentForTrial)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(txtCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jLabel4)
                    .addComponent(txtFee, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtMinPaymentForExam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtMinPaymentForTrial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void txtNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNameActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtNameActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField txtCode;
    private javax.swing.JTextArea txtDiscription;
    private javax.swing.JTextField txtFee;
    private javax.swing.JTextField txtMinPaymentForExam;
    private javax.swing.JTextField txtMinPaymentForTrial;
    private javax.swing.JTextField txtName;
    // End of variables declaration//GEN-END:variables
private master.vehicle_class.object.MVehicalClass vclass;
    @Override
    public Object initObject() {
        vclass.setCode(txtCode.getText());
        vclass.setName(txtName.getText());
        vclass.setDiscription(txtDiscription.getText());
        vclass.setFee(Double.parseDouble(txtFee.getText()));
        vclass.setMinPaymentExam(Double.parseDouble(txtMinPaymentForExam.getText()));
        vclass.setMinPaymentTrial(Double.parseDouble(txtMinPaymentForTrial.getText()));

        return vclass;
    }

    @Override
    public List<Component> getOtherComponent() {
        return Arrays.asList();
    }

    @Override
    public List<Component> getIdentityComponent() {
        return Arrays.asList(
                (Component) txtCode
        );
    }

    @Override
    public List<Component> getEsentialComponent() {
        return Arrays.asList(
                (Component) txtName
        );
    }
   
    @Override
    public void getUnbindObject(Object object) {

    }

    @Override
    public void bindComponents(ArrayList<Object> list, int index) {
        vclass = (MVehicalClass) list.get(index);
        txtCode.setText(vclass.getCode());
        txtName.setText(vclass.getName());
        txtDiscription.setText(vclass.getDiscription());
        txtFee.setText(vclass.getFee().toString());
        txtMinPaymentForExam.setText(vclass.getMinPaymentExam().toString());
        txtMinPaymentForTrial.setText(vclass.getMinPaymentTrial().toString());
    }

    @Override
    public List<Component> componentList() {
        return Arrays.asList(
                (Component) txtCode,
                (Component) txtName,
                (Component) txtDiscription,
                (Component) txtFee,
                (Component) txtMinPaymentForExam,
                (Component) txtMinPaymentForTrial
        );
    }
}
